import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CardPage extends StatelessWidget {
  const CardPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Card Simple"),
      ),
      body: const CardExample(),
    );
  }
}

class CardExample extends StatelessWidget {
  const CardExample({super.key});

  Widget generateCard1() {
    return Card(
      margin: const EdgeInsets.all(20),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          const ListTile(
            leading: Icon(Icons.album),
            title: Text("标题标题标题标题标题标题"),
            subtitle: Text("内容内容内容内容内容内容内容"),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: <Widget>[
              TextButton(onPressed: () {}, child: const Text("按钮1")),
              const SizedBox(width: 20, height: 10),
              TextButton(onPressed: () {}, child: const Text("按钮2")),
            ],
          )
        ],
      ),
    );
  }

  Widget generateCard2() {
    return Card(
      margin: const EdgeInsets.all(20),
      clipBehavior: Clip.hardEdge,
      child: InkWell(
        splashColor: Colors.blue.withAlpha(30),
        onTap: () {
          debugPrint('Card tapped');
        },
        child: const SizedBox(
          width: 300,
          height: 100,
          child: Text("A card that can be tapped"),
        ),
      ),
    );
  }

  generateCard3(context) {
    return const Column(
      children: <Widget>[
        Card(
          child: SizedBox(
            width: 300,
            height: 100,
            child: Center(
              child: Text('Elevated Card'),
            ),
          ),
        ),
        Card(
          elevation: 0,
          color: Colors.greenAccent,
          child: SizedBox(
            width: 300,
            height: 100,
            child: Center(
              child: Text('Filled Card'),
            ),
          ),
        ),
        Card(
          elevation: 0,
          shape: RoundedRectangleBorder(
            side: BorderSide(
              color: Colors.black12,
            ),
            borderRadius: BorderRadius.all(Radius.circular(12)),
          ),
          child: SizedBox(
            width: 300,
            height: 100,
            child: Center(
              child: Text('Outlined Card'),
            ),
          ),
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ListView(
        children: [
          generateCard1(),
          generateCard2(),
          const Center(
            child: Text("不同样式的卡片"),
          ),
          generateCard3(context)
        ],
      ),
    );
  }
}
